import type { FilterItem } from '@/components/FilterBar/types'
import { getUserInfo } from '@/api/eqpt/houseManger'

import { ref } from 'vue'

export const mapOptions: FilterItem[] = [
  {
    label: '名称',
    prop: 'houseName',
    type: 'input',
    span: 4,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '类别',
    prop: 'houseType',
    filterable: true,
    type: 'select',
    span: 4,
    defaultValue: null,
    inputProps: {
      options: [{
        label: '全部',
        value: null
      }]
    }
  },
  {
    label: '编号',
    prop: 'houseCode',
    type: 'input',
    span: 4,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '所在区域',
    prop: 'region',
    filterable: true,
    type: 'select',
    span: 4,
    defaultValue: null,
    inputProps: {
      options: [{
        label: '全部',
        value: null
      }]
    }
  },
  {
    label: '状态',
    prop: 'state',
    filterable: true,
    type: 'select',
    span: 4,
    defaultValue: null,
    inputProps: {
      options: [
        { label: '全部', value: null },
        { label: '使用中', value: '1' },
        { label: '已废弃', value: '2' }
      ]
    }
  }

]
export const dialogOptions = ref<Array<FilterItem>>([
  {
    label: '名称：',
    prop: 'houseName',
    type: 'input',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '类别: ',
    prop: 'houseType',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    inputProps: {
      options: [{
        label: '',
        value: ''
      }]
    }
  },
  {
    label: '编号：',
    prop: 'houseCode',
    type: 'input',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '数量：',
    prop: 'num',
    type: 'inputNumber',
    width: "120px",
    span: 12,
    defaultValue: 1,
    inputProps: {
      clearable: true,
      min: 1,
      max: 1000,
      placeholder: ''
    }
  },
  {
    label: '面积：',
    prop: 'area',
    type: 'inputBtn',
    width: "120px",
    multiple: true,
    span: 12,
    inputProps: {
      clearable: true,
      unit: '㎡',
      placeholder: ''
    }
  },
  {
    label: '单价：',
    prop: 'price',
    type: 'inputBtn',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      unit: '万',
      placeholder: ''
    }
  },
  {
    label: '月租金：',
    prop: 'rent',
    type: 'inputBtn',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      min: 1,
      max: 9999999,
      unit: '元',
      placeholder: ''
    }
  },

  {
    label: '区域：',
    prop: 'region',
    type: 'select',
    width: "120px",
    span: 12,
    filterable: true,
    inputProps: {

      options: []
    }
  },
  {
    label: '地图坐标：',
    prop: 'coordinate',
    type: 'inputBtn',
    width: "120px",
    isDisabled: true,
    defaultValue: null,
    span: 12,
    icon: 'Location',
    inputProps: {
      placeholder: '请输入地图坐标',
      clearable: true
    },
    events: {
      click: () => {
      }
    }
  },
  {
    label: '使用单位：',
    prop: 'useOrgan',
    type: 'treeSelect',
    width: "120px",
    filterable: true,
    span: 12,
    inputProps: {
      'default-expand-all': true,
      data: []
    },
    events: {
      change: (value: any, evt: any) => {
        const params = ref({
          groupIds: [] as any
        })
        params.value.groupIds.length = 0
        params.value.groupIds.push(value)
        getUserInfo(params.value).then(resp => {
          const datas = ref([]) as any
          resp.data.forEach((d: any) => {
            const option = ref({
              label: d.userName,
              value: d.userId
            })
            datas.value.push(option.value)
          })
          evt.setFieldsValue({ linkUser: '' })
          evt.setOptions('linkUser', datas.value)
        })
      }
    }
  },

  {
    label: '状况：',
    prop: 'condition',
    type: 'input',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },

  {
    label: '性质：',
    prop: 'nature',
    type: 'select',
    width: "120px",
    span: 12,
    filterable: true,
    inputProps: {
      options: [{
        label: '',
        value: ''
      }]
    }
  },

  {
    label: '功能：',
    prop: 'ability',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    inputProps: {
      options: []
    }
  },

  {
    label: '维保年限：',
    prop: 'maintainLimit',
    type: 'inputNumber',
    width: "120px",
    span: 12,
    filterable: true,
    inputProps: {
      clearable: true,
      min: 1,
      max: 100,
      placeholder: '请输入'
    }
  },

  {
    label: '上次维保：',
    prop: 'maintainTime',
    type: 'datePicker',
    width: "120px",
    span: 12,
    defaultValue: [],
    inputProps: {
      clearable: true,
      type: 'date'

    }
  },

  {
    label: '责任单位：',
    prop: 'dutyOrganName',
    type: 'treeSelect',
    width: "120px",
    filterable: true,
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      'default-expand-all': true,
      data: []
    }
  },

  {
    label: '联系人：',
    prop: 'linkUser',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      options: []
    }
  },

  {
    label: '联系电话：',
    prop: 'linkPhone',
    type: 'input',
    width: "120px",
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },

  {
    label: '楼层：',
    prop: 'floor',
    type: 'inputNumber',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      min: 1,
      max: 100,
      placeholder: '请输入'

    }
  },

  {
    label: '状态：',
    prop: 'state',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      options: [
        { label: '使用中', value: '1' },
        { label: '已废弃', value: '2' }
      ]
    }
  }

])

export const mapListFilters: FilterItem[] = [
  {
    label: '在维保期限前：',
    prop: 'time',
    type: 'inputNumber',
    span: 16,
    isDisabled: false,
    inputProps: {
      clearable: true,
      min: 1,
      placeholder: ''
    }

  },
  {
    label: '',
    prop: 'unit',
    type: 'select',
    span: 8,
    isDisabled: false,
    inputProps: {
      options: [
        { label: '年', value: 'Y' },
        { label: '月', value: 'M' },
        { label: '季度', value: 'Q' },
        { label: '周', value: 'W' },
        { label: '日', value: 'D' }
      ]
    }
  }]
